<template>
    <div class="song-list">
        <van-nav-bar
        title="歌单详情"
        left-text="返回"
        left-arrow
        @click-left="onClickLeft"
        />
        <div class="header">
            <img :src="song.logo" alt="">
            <h4>{{ song.dissname }}</h4>
            <div class="nick">
                <img :src="song.headurl" alt="">
                <span>{{song.nickname}}</span>
            </div>
            <span>{{song.visitnum | numFilter(1)}}万</span>
        </div>
        <div class="list">
            <van-list
            v-model="loading"
            :finished="finished"
            finished-text="没有更多了"
            @load="onload"
            >
            <div v-for="(item,index) in list" :key="index">
                <h4>{{ item.songname }}</h4>
                <div class="singer" >
                    <span v-for="(singerItem,index) in item.singer" :key="index">
                        {{ singerItem.name }}
                        <span v-show="index != item.singer.length - 1">/</span>
                    </span>
                    <span class="dan">·</span>
                    <span v-show="item.albumname != null">{{ item.albumname }}</span>
                </div>
            </div>
            </van-list>
            
        </div>
    </div>
</template>
<script>


export default {
    data(){
    return{
        // listData:[]
        song:{
            dissname:"",
            logo:"",
            headurl:"",
            nickname:"",
            visitnum:0,
        },
        songlist:[],
        songnum:0,
        list: [],
        Loading: false,
        finished: false,
    };
},
created(){
    this.getSongListData();
},
methods:{
    getSongListData(){
        this.$request('get','/songlist?id='+this.$route.params.id)
        .then(res=>{
            console.log(res)
            this.song.dissname = res.data.dissname;
            this.song.logo = res.data.logo;
            this.song.headurl = res.data.headurl;
            this.song.nickname = res.data.nickname;
            this.song.visitnum  =res.data.visitnum;
            this.songlist  =res.data.songlist;
            this.songnum  =res.data.songnum;
            console.log(this.songlist)
     }
  )
},
//     methods:{
    onClickLeft(){
        window.history.length > 1 ? this.$router.go(-1): this.$router.push('/')
        },
    onload(){
        setTimeout(() =>{
            this.list = this.list.concat(this.songlist.splice(0,10))
            this.loading = false;
            if(this.list.length >= this.songnum){
                this.finished = true;
            }
        },1000);
    }
}
}
</script>
<style scoped>
.head >img{
    border-radius: 1rem;
    width: 50%;
}
.nick{
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1rem;
}
.nick>img{
    height: 2rem;
    border-radius: 50%;
    margin-right: 0.5rem;
}
.nick>span{
    height: 2rem;
    font-size: 0.8rem;
    line-height: 2rem;
}
.list{
    margin: 0 1rem;
}
.list h4{
    text-align: left;
    font-size: 1rem;
}
.singer{
    text-align: left;
}
.singer span{
    font-size: 0.8rem;
    color: rgb(160, 160, 190);
}
.singer>span:nth-last-child(1)>span:nth-child(1){
    color: red;
    font-weight: 900;
    padding: 0 0.5rem;
}
.dan{
    font-weight: 900;
    padding: 0 0.5rem;
}
</style>